

import 'package:local_auth/local_auth.dart';
import 'package:xim/config/store_config.dart';
import 'package:local_auth_android/local_auth_android.dart';

class LoginUtil {

  static final auth = LocalAuthentication();

  /// 指纹校验
  static Future<bool> fingerprintValid() async {
   return await auth.authenticate(
     localizedReason: '请进行身份校验',
     authMessages: <AuthMessages>[
       const AndroidAuthMessages(
         signInTitle: '欢迎回来',
         biometricHint:'',
         cancelButton: 'Cancel',
       ),
     ]
    );
  }

  /// 关闭指纹校验
  static Future<void> closeFingerprint() async {
    StoreApi.instance.changeFingerprintLoginStatus(false);
  }

  /// 开启指纹校验
  static Future<void> openFingerprint() async {
    StoreApi.instance.changeFingerprintLoginStatus(true);
  }

  /// 密码校验
  static Future<bool> passwordValid(String pwd) async {
    var password = await StoreApi.instance.secureTakeAppPassword();
    return pwd == password;
  }

}